package org.tity.test.sql;

import org.tity.sql.dao.DAO;
import org.tity.sql.data.SaveMode;
import org.tity.sql.dialect.SQLDialect;
import org.tity.sql.sql.builder.Update;
import org.tity.test.entity.raw.sys.User;

public class DeleteDemo {

	public static void main(String[] args) {
		
		//创建一个插入语句
		Update update=new Update();
		update.setSQLDialect(SQLDialect.MySQL);
		//设置值
		update.update("sometable").set("id", 1).set("name", "leefj").where().and("id=?",8).top()
		//设置SQL表达式为值
		.setExpr("birthday","now()");
		// 输出 UPDATE sometable SET id=1,name='leefj',birthday=now()  WHERE  id= 8 
		System.out.println(update);
		
		
		//创建一个实体，
		User user=new User();
		//设置值
		user.setAccount("leefj").setAreaType("NingBo").setId(99L).setCardType("VIP");
		//从实体构建 insert 
		update=Update.fromEntity(user,SaveMode.NOT_NULL_FIELDS);
		//输出 UPDATE sys_user SET account='leefj',area_type='NingBo',card_type='VIP'  WHERE  id = 99 
		System.out.println(update);
		
		
		//创建DAO，
		DAO dao = null;
		
		//绑定DAO并执行
		update.setDAO(dao).execute();
	 
		
		//从DAO执行语句
		dao.execute(update);
		
		//从DAO快速执行Update
		dao.update("sometable").set("name","leefj").where().and("id=?",9).execute();
		
		
		
	}
	
}
